<?php get_instance()->view('common/header');?>
<link rel="stylesheet" href="<?php echo $this->staticUrl?>css/jquery-weui.css">
<style type="text/css">
    .PeisPicker {
        /*position: fixed;*/
        left: 0;
        right: 0;
        bottom: 48.5px;
        z-index: 1000;
        background: #FFFFFF;
        opacity: 1;
		
        display: none;
    }
	.shopcarbox{border-top:1px solid #e6e6e6;}
    .bonus,.postal_card,.coupon{color: red}
    .rImg img{width: 100%;}
	.weui-picker-overlay, .weui-picker-container{z-index:99999;}
	.address_a{z-index:99999;position:fixed;top:0;height:100%;}
    .weui-mask{visibility: visible !important;}
    #sdtime{color: red}
	.shangping .itemmodel{border-bottom:1px solid #eee;padding-bottom:1em;}
	.miaoshabox:after{content:'秒杀';text-align:center;width:4em;background:red;color:#fff;position:absolute;left:0;top:0;font-size:0.5em;}
</style>
<body class="bag3">
<div class="areadizbox mb7 bag1">
    <div class="bor_bb pb5">
        <a href="javascript:" class="f12 waper heng vCenter itemitem">
            <div class="left f08 vCenter"><span class="f09"><img class="lefttitleimg mr5 di mbmin" src="<?php echo $this->staticUrl?>img/png/pic25.png" alt="">配送方式</span></div>
            <!-- <div class="right f09 cor6 vCenter"><span class="cor9 f08">消费模式：</span><span class="f08">到店消费</span><div class="rightjbox imgbox f08 ml5"><img class="rightj" src="<?php echo $this->staticUrl?>img/png/pic21.png" alt=""></div></div> -->
        </a>
        <div class="vCenter p3 tabtitle">
            <?php if($shopType == 1):?>
            <b class="hotserchbtn active close-picker" data-type="1">送货上门</b>
            <?php elseif($shopType == 2):?>
            <b class="hotserchbtn active close-picker" data-type="2">到店自提</b>
            <?php else:?>
            <b class="hotserchbtn active close-picker" data-type="1">送货上门</b>
            <b class="hotserchbtn close-picker " data-type="2">到店自提</b>
            <?php endif;?>
        </div>
    </div>
    <div class="waper heng vCenter oh tabcons userAddress" style="height:0;">
        <?php //if (!empty($address)):?>
            <div class="pt5 pb5 pr">
                <h1 class="mbmin textEll"><?php echo isset($address['consignee'])?$address['consignee']:'暂无收货人'?>
                    <?php if(isset($address['gender']) && $address['gender'] == 1):?>
                        先生
                    <?php endif;?>
                    <?php if (isset($address['gender']) && $address['gender'] == 2):?>
                        女士
                    <?php endif;?>
                    <span class="ml10"><?php echo isset($address['mobile'])?$address['mobile']:'';?></span></h1>
                <div class="cons hengleft">
                    <div class="left imgbox mr5 mtmin mapicon"><img src="<?php echo $this->staticUrl?>img/png/pic24.png" alt=""></div>
                    <p class="f08 cor6 pr5"><?php echo isset($address['_address'])?$address['_address']:'暂无地址'?></p>
                </div>
            </div>
        <?php //else:?>
            <!--<div>请添加收货地址</div>-->
        <?php //endif;?>
        <div class="rightjbox imgbox"><img class="rightj" src="<?php echo $this->staticUrl?>img/png/pic21.png" alt=""></div>
    </div>
    <div class="tabcons oh " style="height:0;">
        <div class="waper heng vCenter">
            <div class="pt5 pb5 wp100 pr">
                <h1 class="mbmin textEll f09"><img class="lefttitleimg mr5 di mbmin f09" src="<?php echo $this->staticUrl?>img/png/pic25.png" alt=""><?php echo $mAddress['shop_name']?></h1>
                <div class="cons heng wp80">
                    <p class="f08 cor6 pr5 textEll pl20"><?php echo $mAddress['address_desc']?></p>
                </div>
                <div class="pos posrightcenterimg imgbox"><a href="<?php echo getUrl('common/merchantMap?shop_name='.$mAddress['shop_name'].'&mobile='.$mAddress['mobile'].'&lat='.$mAddress['latitude']).'&lng='.$mAddress['longitude']?>"><img src="<?php echo $this->staticUrl?>img/png/pic100.png" alt=""></a></div>
            </div>
<!--            <div class="rightjbox imgbox"><img class="rightj" src="--><?php //echo $this->staticUrl?><!--img/png/pic21.png" alt=""></div>-->
        </div>
        <div class="waper bor_tt heng vCenter">
            <h1 class="mbmin textEll f09"><img class="lefttitleimg mr5 di mbmin f09" src="<?php echo $this->staticUrl?>img/png/pic101.png" alt="">营业时间</h1>
            <div class="p5_0">
                <p class="f07 tr cor8">
                <?php foreach ($_time as $k=>$v):?>
                <?php echo $v['business_time_start'].' - '.$v['business_time_end']?>
                <?php endforeach;?>
                </p>
                <p class="f06 tr cor8"><?php echo $mAddress['week_str'];?></p>
            </div>
        </div>
    </div>
</div>
<?php foreach ($order as $k=>$v):?>
<div class="bag1">
    <a href="" class="f12 waper  bor_bt heng vCenter itemitem">
        <div class="left f08 vCenter">
            <span class="f09"><img class="lefttitleimg mr5 di mbmin" src="<?php echo $this->staticUrl?>img/png/pic25.png" alt=""><?php echo $v['name']?></span>
        </div>
        <!-- <div class="right f09 cor6 vCenter"><span class="cor9 f08">消费模式：</span><span class="f08">到店消费</span><div class="rightjbox imgbox f08 ml5"><img class="rightj" src="<?php echo $this->staticUrl?>img/png/pic21.png" alt=""></div></div> -->
    </a>
</div>
<div class="bag1 orderwaper ">
	<div class="shangping oh">
		<?php foreach ($v['list'] as $kk=>$vv):?>
		<div class="itemmodel">
			<div class="item-left">
				<div class="item-img <?php if($vv['is_special'] == 2):?>pr miaoshabox<?php endif;?>" style="width:4em;height:4em;"><img alt="" style="width: 100%;" src="<?php echo $vv['icon']?>"></div>
			</div>
			<div class="item-right">
				<div class="mltitle"><?php echo mb_substr($vv['name'],0,20,'utf-8');?></div>
				<div class="subtitle">
					<?php if($vv['property']):?>
					规格:<?php echo $vv['property']?>
					<?php endif;?>
					<?php if($vv['tags']):?>
						属性：<?php echo $vv['tags']?>
					<?php endif;?>
				</div>
				<div class="price"><span class="xian">¥<?php echo $vv['price']?></span>
                    <?php if($vv['market_price'] > 0):?>
                    <span class="yuan">¥<?php echo $vv['market_price']?></span>
                    <?php endif;?>
                </div>
				<div class="zengjian">
					<span class="f07 cor9">x<?php echo $vv['b_quantity']?></span>
				</div>
			</div>
		</div>
		<?php endforeach;?>
	</div>
	<div class="tc mt5"><a href="javascript:;" class="f08 cor6 tc selectshop">查看更多</a></div>
    <div class="weui-cells orderinfo mt5">
        <a class="weui-cell weui-cell_access p7_0" id="showPicker" href="javascript:;">
            <div class="weui-cell__bd">
                <p class="f08 _times">送达时间</p>
            </div>
            <div class="weui-cell__ft f08 cor6 " id="sdtime">

                <?php echo $data[0]['expect_arrive_time']?>
            </div>
        </a>
        <?php if ($v['is_coupon'] == 2):?>
        <a class="weui-cell weui-cell_access p7_0 " href="javascript:;">
            <div class="weui-cell__bd">
                <p class="f08">代金劵</p>
            </div>
            <div class="weui-cell__ft f08 cor6 coupon" couponid = '0'>
                <?php if($coupon):?>
                    <?php echo count($coupon).'张可用'?>
                <?php else:?>
                    暂无可用
                <?php endif;?>
            </div>
        </a>
        <?php endif;?>
        <?php if ($v['is_bonus'] == 2):?>
        <a class="weui-cell weui-cell_access p7_0" href="javascript:;">
            <div class="weui-cell__bd">
                <p class="f08">红包</p>
            </div>
            <div class="weui-cell__ft f08 cor6 bonus" bonusid = '0'>
                <?php if($bonus):?>
                    <?php echo count($bonus).'张可用'?>
                <?php elseif($isSpecial):?>
                秒杀商品不支持红包
                <?php else:?>
                    暂无可用
                <?php endif;?>
            </div>
        </a>
        <?php endif;?>
        <a class="weui-cell weui-cell_access p7_0" href="javascript:;">
            <div class="weui-cell__bd">
                <p class="f08">包邮卡</p>
            </div>
            <div class="weui-cell__ft f08 cor6 postal_card" postal_card_id = '0'>
                <?php if(!empty($postalCard)):?>
                    <?php echo count($postalCard).'张可用'?>
                <?php else:?>
                    暂无可用
                <?php endif;?>
            </div>
        </a>
        <div class="orderyouhui">
            <?php if($v['first_order_reduce'] > 0):?>
            <a class="weui-cell weui-cell_access p5_0" href="javascript:;">
                <div class="weui-cell__bd">
                    <p class="f08">新用户立减</p>
                </div>
                <div class="f08 cor6">
                    - ¥ <?php echo $v['first_order_reduce']?>
                </div>
            </a>
            <?php endif;?>
            <a class="weui-cell weui-cell_access p5_0" href="javascript:;">
                <div class="weui-cell__bd">
                    <p class="f08">减配送费</p>
                </div>
                <div class="f08 cor6">
                    - ¥ <?php echo $v['full_cut']['money']?>
                </div>
            </a>
        </div>
        <a class="weui-cell weui-cell_access p7_0" href="javascript:;">
            <div class="weui-cell__bd">
                <p class="f08">打包费</p>
            </div>
            <div class="f08 cor6">
                ¥ <?php echo $v['lunch_box_fee']?>
            </div>
        </a>
        <a class="weui-cell weui-cell_access p7_0 showPeisPicker" id="expense_type" href="javascript:;">
            <div class="weui-cell__bd">
                <p class="f08">配送费</p>
            </div>
            <div class="weui-cell__ft f08 cor6" id="shipping_fee_">¥ <?php echo $fee[0]['shipping_fee'];?></div>
        </a>
		<a class="weui-cell weui-cell_access p7_0" href="javascript:;">
            <div class="weui-cell__bd shuserboxi">
                <p class="f08">如遇缺货</p>
            </div>
            <div class="weui-cell__ft f08 cor6"></div>
        </a>
        <a class="weui-cell weui-cell_access p7_0" href="javascript:;">
            <div class="weui-cell__bd">
                <input type="text" placeholder="选填：给商家留言" class="wp100 b0 f08 _input">
            </div>
        </a>
    </div>
</div>
<?php endforeach;?>
<div class="shopcarbox orderbottom">
    <div class="left p3 pt5 pbmin">
        <p class="lh10 pt5"><span class="hongzi f11 lh10 ">¥<c id="total_" style="font-size: 20px;"><?php echo $total;?></c></span><span class="f06 cor9"> (优惠：¥<c id="s_money">0</c>)</span></p>
<!--        <p class="cor8 f07 " id="expect">预计-->
<!--            --><?php //echo isset($wxDefaultTime['date'])?$wxDefaultTime['date']:'';?>
<!--            --><?php //echo isset($wxDefaultTime['time'])?$wxDefaultTime['time']:'';?>
<!--            到达</p>-->
    </div>
    <div class="right">
        <span style="visibility:hidden"></span>
        <span class="" id="goPay">去支付</span>
    </div>
</div>
<div class="mask"></div>
<div class="PeisPicker FeiXibox">
    <div class="dialogtitle">
        <div></div><!-- 这个标签必须要！ -->
        <div class="">费用明细</div>
        <a class="f07 rule" href="javascript:;">价格规则 ></a>
    </div>
    <div class="dialogcons">
        <div class="vCenter heng">
            <p>基础配送费</p>
            <p class="cor6" id="base_amount_">¥ <?php echo isset($fee[0]['base_amount'])?$fee[0]['base_amount']:'0'?></p>
        </div>
        <div class="vCenter heng">
            <p>距离附加 <span class="f10 cor6" id="exceed_distance_"><?php echo round(isset($fee[0]['exceed_distance'])?$fee[0]['exceed_distance']/1000:0,2)?>公里</span></p>
            <p class="cor6" id="distance_amount_">¥ <?php echo round(isset($fee[0]['distance_amount'])?$fee[0]['distance_amount']:0,2)?></p>
        </div>
        <div class="vCenter heng">
            <p>重量附加 <span class="f10 cor6" id="exceed_weight_"><?php echo isset($fee[0]['weight'])?$fee[0]['weight']:0;?>公斤</span></p>
            <p class="cor6" id="weight_amount_">¥ <?php echo isset($fee[0]['weight_amount'])?$fee[0]['weight_amount']:0;?></p>
        </div>
    </div>
    <div class="dialogbtn bor_tt">
        <div class="heng vCenter">
            <p class="f08">
                <span id="distance_">
                    <?php echo round(isset($fee[0]['distance'])?$fee[0]['distance']/1000:0,2)?>公里
                </span>
                <span class="f10 lanzi " id="expect">
                    预计
                    <?php if($wxDefaultTime['date'] == $day):?>
                            今日
                        <?php else:?>
                        明日
                    <?php endif;?>
                    <?php echo $wxDefaultTime['time'];?>
                    到达</span>
            </p>
            <span class="hongzi" id="shipping_fee__">¥ <?php echo isset($fee[0]['shipping_fee'])?$fee[0]['shipping_fee']:0?></span>
        </div>
        <a href="javascript:" class="kbtn" id="qd_">确 定</a>
    </div>
</div>
<div class="mask"></div>
<div class="PeisPicker FeiRule">
    <div class="dialogtitle">
        <div></div><!-- 这个标签必须要！ -->
        <div class="">价格规则</div>
        <a class="f07 rule" href="javascript:;"></a>
    </div>
    <div class="rImg">
        <?php echo $distribution?>
    </div>
</div>
<div class="PeisPicker Quehuodialbox">
    <div class="dialogtitle">
        <a class="f09 qh_cancel" href="javascript:">取消</a>
        <div class="">商家缺货</div>
        <a class="f09 qh_ok" href="javascript:">确定</a>
    </div>
    <div class="weui-cells weui-cells_radio mt0">
    	<?php foreach ($data[0]['shortage_handing_s'] as $k=>$v):?>
        <label class="weui-cell weui-check__label" for="x1<?php echo $k+1?>">
            <div class="weui-cell__bd">
                <p class="f08 cor6"><?php echo $k+1?>、<?php echo $v['label']?></p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" data-id="<?php echo $v['value']?>" name="radio1" id="x1<?php echo $k+1?>"<?php if($k==0){echo 'checked="checked"';}?>/>
                <span class="weui-icon-checked shortage_checked" data-id="<?php echo $v['value']?>"></span>
            </div>
        </label>
        <?php endforeach;?>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <textarea class="weui-textarea f08 remark_" placeholder="请输入文本" rows="3"></textarea>
                <div class="weui-textarea-counter f08"><span class="f10"><c id="pattern">0</c></span>/200</div>
            </div>
        </div>
    </div>
</div>
<div class="PeisPicker addressbox address_a" style="bottom:0;">
    <div class="dialogtitle">
        <a class="f09" href="javascript:">取消</a>
        <div class="">收货地址</div>
        <a class="f09" href="javascript:">确定</a>
    </div>
    <div class="addressbox weui-cells weui-cells_radio mt0">

    </div>
</div>
<script src="<?php echo $this->staticUrl?>js/jquery-weui.js"></script>
<script type="text/javascript">
var param = eval('<?php echo json_encode($data)?>');
var address_id = <?php echo !empty($address) ? $address['id'] : 0?>;
//var total = <?php //echo $total - $fee[0]['shipping_fee'] ;?>//; // 总价（不含运费）
var total = <?php echo $totalAmount ;?>; // 商品总额+餐费费
var fee = <?php echo $fee[0]['shipping_fee'];?>; // 配送费
var coupon = 0;
var bonus = 0;
var postalCard = 0;
var smoney = 0;
var productJson = '<?php echo $productJson;?>';
var fullcut = <?php echo $fullcut;?>;
var firstorder = <?php echo $firstOrder;?>;
var day = "<?php echo $day?>"; // 今日日期
var dayStr = "<?php echo $day_str?>"; // 今日日期
var times = "<?php echo $time?>"; // 送货上门 -- 第一个时间
var selfTime = "<?php echo $selfTime?>"; // 到店自提 -- 第一个时间
var shopType = "<?php echo $shopType;?>";
var shipType = "<?php echo $shopType==3?1:$shopType;?>";
var pC = 0,picker,time,tName = '立即送达' ;
var wxSDTime = eval('<?php echo $wxSDTime;?>'); // 送货上门 -- 送达时间
var selfLiftingTime = eval('<?php echo $selfLiftingTime;?>');  // 到店自提  -- 自提时间
time = times;
param[0]['expect_arrive_time'] = day + ' ' + time;
//console.log(param)
$(function () {
    sessionStorage.setItem("need-refresh", true);

    $(".tabcons").eq(0).css("height","auto");

    if(shopType == 2){
        setExpenseType(shopType);
    }

    switch(shopType)
    {
        case "1":
            $(".tabcons").eq(0).css("height","auto").siblings(".tabcons").css("height","0");
            break;
        case "2":
            console.log(shopType);
            $(".tabcons").eq(1).css("height","auto").siblings(".tabcons").css("height","0");
            break;
        default:
            $(".tabcons").eq(0).css("height","auto").siblings(".tabcons").css("height","0");
            break;
    }
});
function setExpenseType(type){
	if(type == 1){
		//送货上门
		param[0].expense_type = 1;
        var total_pirce = parseFloat(total) + parseFloat(fee);
        setSMoney();
        total_pirce -=smoney;
        if(total_pirce<0){
            total_pirce = 0;
        }
        total_pirce = parseFloat(total_pirce.toFixed(2));

		$('#total_').text(total_pirce);
		$('#expense_type').show();
		$("._times").text('送达时间');
        $(".postal_card").parents('a').show();
        picker = wxSDTime;
        //time = times;
        tName = '立即送达';
        $('#sdtime').text(' ' + tName + '(预计'+ dayStr+time + ')');
        param[0]['expect_arrive_time'] = day + ' ' + time;
	}else if(type == 2){
		//上门自取
		param[0].expense_type = 2;
        var total_pirce = parseFloat(total);
        setSMoney();
        console.log('smone'+smoney)
        total_pirce -= smoney;
        if(total_pirce<0){
            total_pirce = 0;
        }
        total_pirce = parseFloat(total_pirce.toFixed(2));
        $('#total_').text(total_pirce);
        $(".postal_card").parents('a').hide();
		$('#expense_type').hide();
        $("._times").text('自提时间');
        picker = selfLiftingTime;
        //time = selfTime;
        tName = '立即自提';
        $('#sdtime').text(' ' + tName + '(预计'+ dayStr + selfTime + ')');
        param[0]['expect_arrive_time'] = day + ' ' + selfTime;
	}

//	console.log(param);
}

function changeAddress(){
    $.post("<?php echo getUrl('product/getShippingFee');?>",{product:productJson,address_id:address_id},function (res) {
        var data = res.data[0];
        console.log(data);
        $("#shipping_fee_").text("￥"+data.shipping_fee);
        $("#shipping_fee__").text("￥"+data.shipping_fee);
        $("#base_amount_").text("￥"+data.base_amount);
        $("#distance_amount_").text("￥"+data.distance_amount);
        $("#exceed_weight_").text(data.exceed_weight+"公斤");
        $("#weight_amount_").text("￥"+data.weight_amount);
        if(data.exceed_distance!=null){
            var ed = data.exceed_distance / 1000.0;
            $("#exceed_distance_").text(ed.toFixed(2)+'公里');
        }

        if(postalCard){
            if(parseFloat(data.shipping_fee) > postalCard){
                $(".postal_card").html("-"+postalCard);
            }else{
                $(".postal_card").html("-"+data.shipping_fee);
            }
        }
        $("#distance_").text((data.distance / 1000.0).toFixed(2)+'公里');
        $("#expect").html("预计"+data.date+data.time+"到达");

        fee = data.shipping_fee;
        time = data.time;
        day = data.date;
        param[0]['fee'] = data.shipping_fee;
        setExpenseType(shipType);
    },'json')
}


function setSMoney(){
    //设置优惠金额
    var post = 0;
    if(param[0].expense_type == 1){
        post = postalCard;
        if(parseFloat(postalCard)>parseFloat(fee)){
            post = fee;
        }
    }
    $('#s_money').text(parseFloat(bonus)+parseFloat(coupon)+parseFloat(fullcut)+parseFloat(firstorder)+parseFloat(post));
    smoney= parseFloat(bonus)+parseFloat(coupon)+parseFloat(fullcut)+parseFloat(firstorder)+parseFloat(post);
}

$(function(){
    setSMoney();
	//代金券
    $(".coupon").select({
        title: "选择代金券",
        items:eval('<?php echo json_encode($coupon)?>'),
        onClose:function () {
            value = $(".coupon").attr('data-values');
            if (value == undefined){
                return;
            }

            var cat = $(".coupon").attr('value');
            value = value.split(',');
            $(".coupon").html('-'+value[1]);
            if($(".coupon").attr('couponid') == value[0]){
                return;
            }
            param[0].coupon_id = value[0];//设置红包id
            coupon = value[1];
            var total_pirce = parseFloat(total) + parseFloat(fee);
            setSMoney();
            total_pirce -=smoney;
            if(total_pirce<0){
                total_pirce = 0;
            }
            total_pirce = parseFloat(total_pirce.toFixed(2));
            $('#total_').text(total_pirce);
            $(".coupon").attr('couponid',value[0]);
        }

    });
    //红包
    $(".bonus").select({
        title: "选择红包",
        items:eval('<?php echo json_encode($bonus)?>'),
        onClose:function () {
            value = $(".bonus").attr('data-values');
            if (value == undefined){
                return;
            }
            var cat = $(".bonus").attr('value');
            value = value.split(',');
            $(".bonus").html('-'+value[1]);
            if($(".bonus").attr('bonusid') == value[0]){
                return;
            }
            param[0].bonus_id = value[0];//设置红包id
            bonus = value[1];
            var total_pirce = parseFloat(total) + parseFloat(fee);
            setSMoney();
            total_pirce -=smoney;
            if(total_pirce<0){
                total_pirce = 0;
        	}
            total_pirce = parseFloat(total_pirce.toFixed(2));
            $('#total_').text(total_pirce);
            $(".bonus").attr('bonusid',value[0]);
        }

    });
    //包邮卡
    $(".postal_card").select({
        title: "选择包邮卡",
        items:eval('<?php echo json_encode($postalCard)?>'),
        onClose:function () {
            var pc = $(".postal_card");
            value = pc.attr('data-values');
            if (value == undefined){
                return;
            }
            value = value.split(',');
            if(parseFloat(value[1]) > parseFloat(fee)){
                $(".postal_card").html('-'+fee);
            }else {
                $(".postal_card").html('-'+value[1]);
            }

            if(pc.attr('postal_card_id') == value[0]){
                return;
            }

            param[0].postal_card_id = value[0];
            postalCard = value[1];
            var total_pirce = parseFloat(total) + parseFloat(fee);
            setSMoney();
            total_pirce -=smoney;
            if(total_pirce<0){
                total_pirce = 0;
            }
            total_pirce = parseFloat(total_pirce.toFixed(2));
            $('#total_').text(total_pirce);
            pc.attr('postal_card_id',value[0]);
        }
    });

	$('#goPay').click(function(){

//		console.log(param);
		if(param.expense_type == 1){
			//送货上门
			if(address_id <= 0){
				//地址必修
				show_message({status:0,message:'请选择送货地址'});
			}
		}else if(param.expense_type == 2){
			//自取
		}
		blockUI.show('提交中');
		$.post("<?php echo getUrl('product/orderSm')?>",{param:JSON.stringify(param),address_id:address_id},function(data){
			
			 data = JSON.parse(data);
			 console.log(data)
			if(data.status == 1){
				show_message(data);
				blockUI.hide();
				window.location.href = '<?php echo getUrl('product/orderPay?code=')?>'+data.data.code
			}else{
				show_message(data);
				blockUI.hide();
			}
			
		})
	})
	var limitNum = 200;
	var value1 = '',value2 = '';
	
	//备注
	$(document).on('input propertychange', '._input', function() {
		
		var remain = $(this).val().length;
		
		param[0].remark = $(this).val();//设置选中的缺货处理备注
		
        if(remain > limitNum){
        		$(this).val(value1)
                pattern = "字数超过限制！";
        }else{
            var result = limitNum - remain;
            pattern = '还可以输入' + result + '字符';
            value1 = $(this).val()
        }
        $('#pattern').text(pattern);
	    //alert('input textarea change');
	});

	//缺货备注
	
	$(document).on('input propertychange', 'textarea', function() {
		var remain = $(this).val().length;
		
		param[0].shortage_handing.remark = $(this).val();//设置选中的缺货处理备注
		
        if(remain > limitNum){
        		$(this).val(value2)
                pattern = "字数超过限制！";
        }else{
            var result = limitNum - remain;
            pattern = '还可以输入' + result + '字符';
            value2 = $(this).val()
        }
        $('#pattern').text(pattern);
	    //alert('input textarea change');
	});
	
	//点击
	$('.shortage_checked').click(function(data){
		var value = $(this).attr('data-id');
		param[0].shortage_handing.value = value;//设置选中的缺货处理
	})
	
	//商家缺货
	$(".shuserboxi").on("click",function(){
		let _height  = $(".shopcarbox").height();
		$(".mask").fadeIn(500);
		$(".Quehuodialbox").fadeIn(300);
//		$(".Quehuodialbox").animate({
//			bottom: _height, opacity: '1'
//		}, 300);
		$(".shopcarbox").css("z-index","1001");

		//获取默认的值
		var value = $('[name="radio1"]:checked').attr('data-id');
		param[0].shortage_handing.value = value;//设置选中的缺货处理
	})
	
		//点击遮罩
	$(".mask").on("click",function(){
        var f = $(".FeiRule").css('display');
        if (f == 'block'){
            $(".FeiRule").fadeOut(300);
            $(".FeiXibox").fadeIn(300);
        }else{
            $(".mask").fadeOut(300);
            $(".PeisPicker").fadeOut(300);
            $(".Quehuodialbox").fadeOut(300);
            $(".addressbox").hide()
            setTimeout(function(){
                $(".shopcarbox").css("z-index","9999");
            },500)
        }
//		$(".PeisPicker").animate({
//			bottom: '-100%', opacity: '0'
//		}, 300);
//		$(".Quehuodialbox").animate({
//			bottom: '-100%', opacity: '0'
//		}, 300);
	});
	
	$('.qh_cancel').click(function(){
		$(".mask").fadeOut(300);
		$(".Quehuodialbox").fadeOut(300);
//		$(".Quehuodialbox").animate({
//			bottom: '-100%', opacity: '0'
//		}, 300);
		setTimeout(function(){
			$(".shopcarbox").css("z-index","2");
		},500)
	})

    $('#qd_').click(function(){
		$(".mask").fadeOut(300);
		$(".PeisPicker ").fadeOut(300);
		setTimeout(function(){
			$(".shopcarbox").css("z-index","2");
		},500)
	})
	
	$('.qh_ok').click(function(){
		$(".mask").fadeOut(300);
		$(".Quehuodialbox").fadeOut(300);
		setTimeout(function(){
			$(".shopcarbox").css("z-index","2");
		},500)
	})
	
    $('.userAddress').click(function () {
         let _height  = $(".shopcarbox").height();
         $(".mask").fadeIn(500);
         $(".addressbox").fadeIn(300);
         html = '<iframe style="width:100%;height:100%;" frameborder="0" src="<?php echo getUrl("user/address?product=1&latitude={$lat}&longitude=${lng}");?>"></iframe>';
         $('.addressbox').html(html);
    });

	//送达时间
	var defaultTime = eval('[<?php echo json_encode($wxDefaultTime);?>]')[0];
    picker = wxSDTime;
//	console.log(picker)
    $('#showPicker').on('click', function () {
        var name = 'sdtime';
    	_picker = $(this);
        weui.picker(picker, {
            id:name,
        	defaultValue:[defaultTime['date'],defaultTime['time']],
            onChange: function (result) {
//                 console.log(result);
            },
            onConfirm: function (result) {

                if (day == result[0]){
                    if (time == result[1]){
                        $('#sdtime').text(' ' + tName + '（预计'+result[1]+'）');
                    }else{
                        $('#sdtime').text(dayStr+' '+result[1]);
                    }
                    $('#expect').text(dayStr+' ' +result[1] + '送达');
                }else{
                    if(selfTime == result[1]){
                        $('#sdtime').text(' ' + tName + '（预计'+result[1]+'）');
                    }else{
                        $('#sdtime').text(dayStr+' '+result[1]);
                    }

                    $('#expect').text('预计' + result[0]+' '+result[1] + '送达');
                }

                param[0]['expect_arrive_time'] = result[0]+' '+result[1];


               	if(typeof goPicker == 'function'){
            		goPicker(name,result);
            	}
            }
        });
    });

    $(".rule").click(function () {
        $(".FeiRule").fadeIn(300);
        $(".FeiXibox").fadeOut(300);
    })
})

</script>
<script>
	$(function(){
		var gaodu = $(".itemmodel").innerHeight();
		if($(".shangping .itemmodel").length>=3){
			$(".shangping").height(gaodu*2+4);
			$(".selectshop").text("查看更多");
		}else{
			$(".selectshop").text("收起");
			return false;
		}
		$(".selectshop").click(function(){
			if($(this).text()=="查看更多"){
				$(".shangping").height(gaodu*$(".shangping .itemmodel").length+5);
				$(".selectshop").text("收起");
			}else{
				$(".shangping").height(gaodu*2+4);
				$(".selectshop").text("查看更多");
				return false;
			}
		})
	})
</script>
</body>

<script src="<?php echo $this->staticUrl?>js/base.js"></script>
</html>